<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="white" />
    <title></title>
    <link rel="stylesheet" href="../public/css/weui.css" />
    <link rel="stylesheet" href="../public/css/jquery-weui.css">
    <link rel="stylesheet" href="../public/css/common.css" />
    <link rel="stylesheet" href="css/index.css" />
	<style>
		[v-cloak]{
			display: none;
		}
	</style>
</head>
<body style="background: #FFFFFF;">
<div id="digindex">
	<div>
		<div style="height: 1.8rem;"></div>
		<div class="public_top_header">
			<a class="weui-cell">
				<div class="weui-cell__hd">
					<img src="../public/images/yunkuanglogo.png" />
				</div>
				<div class="weui-cell__bd" style="margin-left: 0.2rem;">矿机</div>
				<div class="weui-cell__ft more" id="more">
					<img src="../public/images/more.png">
				</div>
			</a>
		</div>
	</div>
	<div :class="{'showajax':!showbuymill,'hideajax':showbuymill}">
		<div style="height: 1.8rem;"></div>
		<div class="buybill-mybill-msg" v-cloak>
			<div class="item">矿机总额度: <span>{{totalquota}}</span> 万</div>
			<div class="item">已使用额度: <span>{{usagequota}}</span> 万</div>
			<div class="item">未使用额度: <span style="color: #FD2727;">{{residualquota}}</span> 万</div>
			<div class="item">矿机数量: <span>{{mymilllist.length}}</span> 台</div>
		</div>
		<div class="digindex-mymill-list" v-cloak>
			<div class="item" v-for="item in mymilllist">
				<div class="digindex-mymill-number weui-cell">
					<div class="weui-cell__bd">{{item.name}}</div>
					<div class="weui-cell__ft">{{item.mill.name}}</div>
				</div>
				<img class="mill-img" :src="'..'+item.mill.millPhoto" @click="jumpToDetail(item.id)" />
				<div class="weui-cell digindex-mymill-earnings">
					<div class="weui-cell__hd">累计收益:{{item.allincome}}</div>
					<div class="weui-cell__bd">昨日收益：{{item.yesterdayincome}}</div>
					<div class="weui-cell__ft" @click="harvesters(item.id)">收矿</div>
				</div>
				<div class="weui-cell digindex-mill-parameter">
					<div class="weui-cell__hd">算力天数:<span>{{item.mill.daysNum}}</span>天</div>
					<div class="weui-cell__bd">收益:<span>{{item.mill.rate*100}}%</span></div>
					<div class="weui-cell__ft">每日算力:<span>{{item.mill.arithmeticStrength}}</span></div>
				</div>
			</div>
		</div>
		<img src="../public/images/addmill.png" class="addmillbtn" @click="showbuygoods" />
		<img src="../public/images/kjjmqd.png" class="kjjmqd" @click="toWallet()"/>
	</div>
	<div class="digindex-mill-list" :class="{'showajax':showbuymill,'hideajax':!showbuymill}" v-cloak>
		<div class="item" v-for="item in milllist">
			<img class="mill-img" :src="'..'+item.millPhoto" />
			<div class="weui-cell digindex-mill-earnings">
				<div class="weui-cell__hd">{{item.name}}</div>
				<div class="weui-cell__bd">{{item.limitStart}}~{{item.limitEnd}}云币</div>
				<div class="weui-cell__ft" @click="jumpToCreate(item.name,item.id)">购买</div>
			</div>
			<div class="weui-cell digindex-mill-parameter">
				<div class="weui-cell__hd">算力天数:<span>{{item.daysNum}}</span>天</div>
				<div class="weui-cell__bd">收益:<span>{{item.rate*100}}</span></div>
				<div class="weui-cell__ft">每日算力:<span>{{item.arithmeticStrength}}</span></div>
			</div>
		</div>
	</div>
	<div style="height: 1.4rem;"></div>
	<div class="common-bottom">
		<ul>
			<li>
				<a href="index.html">
					<div class="icon icon-1"></div>
					<div class="text">首页</div>
				</a>
			</li>
			<li class="active">
				<a href="buymill.html">
					<div class="icon icon-2"></div>
					<div class="text">矿机</div>
				</a>
			</li>
			<li>
				<a href="../wallet/index.html">
					<div class="icon icon-3"></div>
					<div class="text">钱包</div>
				</a>
			</li>
			<li>
				<a href="../personal/index.html">
					<div class="icon icon-4"></div>
					<div class="text">我的</div>
				</a>
			</li>
		</ul>
	</div>
	
</div>
<script type="text/javascript" src="../public/js/jquery-2.1.4.js"></script>
<script src="../public/js/jquery-weui.js"></script>
<script type="text/javascript" src="../public/js/vue.js" ></script>
<script type="text/javascript" src="../public/js/font_size.js" ></script>
<script type="text/javascript" src="../public/js/common.js" ></script>
<script type="text/javascript">
    $(function(){
        var vm = new Vue({
            el:"#digindex",
            data: {
            	showbuymill:false,
				totalquota:0,
                residualquota:0,
                usagequota:0,
            	mymilllist:[],
            	milllist:[],
                canusegolb:[]
            },
            methods:{
				showbuygoods:function(){
					this.showbuymill = true;
				},
                jumpToCreate:function(name,id){
                    local.saveData("milldetail",{
                        millname:name,
                        millid:id
                    })
                    window.location.href="./createmill.html";
                },
				jumpToDetail:function (id) {
                   location.href='./millshow.html?millid='+id
                },
                harvesters:function(millid){
				    AjaxRequest({
                        url:_url+"/money/mill/findOutputMoney",
                        data:{
                            millid:millid
                        },
                        type:"post",
						success:(res)=>{
                            this.canusegolb = res.data;
                            if(this.canusegolb.length>0)
                                AjaxRequest({
                                    url:_url+"/money/mill/onekeyMill",
                                    data:{
                                        userid:local.getData("yb_user_info").id,
                                        myMillid :millid
                                    },
                                    type:"post",
                                    success(res){
                                        if(res.code==1){
                                            AjaxRequest({
                                                url:_url+"/money/mill/mymill",
                                                data:{
                                                    userid:local.getData("yb_user_info").id,
                                                },
                                                type:"post",
                                                success(res){
                                                    var mills=res.data.mymills;
                                                    for(var i=0;i<mills.length;i++){
                                                        if(mills[i].mill.$ref){
                                                            var a = mills[i].mill.$ref.split("[")[1];
                                                            var b = a.split("]")[0];
                                                            mills[i].mill=mills[b].mill;
                                                        }
                                                    }
                                                    vm.mymilllist=mills;
                                                }
                                            })
                                            harvestersanimationother();
                                        }
                                    }
                                });
                            else
							{
                                $.alert("暂时没有挖出新币，等会儿再来吧！");
							}
						}
					});

                },
                toWallet:function(){
                    location.href='../wallet/index.html';
                }
            },
            created:function(){
                var id=local.getData("yb_user_info").id;
                AjaxRequest({
                    url:_url+"/money/mill/mymill",
                    type:"post",
					load:true,
                    data:{
                        userid:id
                    },
                    success(res){
                        if(res.code==1)
                        {
                            vm.totalquota=Number(res.data.totalquota/10000).toFixed(1);
                            vm.residualquota=Number(res.data.residualquota/10000).toFixed(1);
                            vm.usagequota=Number(res.data.usagequota/10000).toFixed(1);
                            var mills=res.data.mymills;
                            for(var i=0;i<mills.length;i++){
                                if(mills[i].mill.$ref){
                                    var a = mills[i].mill.$ref.split("[")[1];
                                    var b = a.split("]")[0];
                                    mills[i].mill=mills[b].mill;
                                }
                            }
                            vm.mymilllist=mills;
                        }
                          if(vm.mymilllist.length<1){
                            vm.showbuymill = true;
                        }
                    }
                });
                AjaxRequest({
                    url:_url+"/money/mill/millall",
                    load:true,
                    type:"post",
                    success(res){
                        if(isReqSucceed(res))
                            vm.milllist=res.data;
                    }
                })
            }
        });
        $("#more").click(function () {
            $.actions({
                actions:[{
                    text:"扫一扫",
                    onClick:function() {
                        $(window).attr("location","../wallet/trans-accounts.html?type=0")
                    }
                },{
                    text:"分享推广",
                    onClick:function () {
                        $(window).attr("location","../personal/share.html")
                    }
                },{
                    text:"关于云矿",
                    onClick:function () {
                        $(window).attr("location","../personal/about-us.html")
                    }
                }]
            })
        }
		)
    })
</script>
</body>
</html>



